// ==UserScript==
// @name         知群小助教批改列表自动刷新
// @namespace    http://tampermonkey.net/
// @version      20210813.072302
// @description  本文件专用于TamperMonkey自动下载脚本，是一个便于本地调试编程的脚本
// @author       You
// @match        https://izhiqun.com/boss/teach/hw-correct
// @grant        none
// @updateURL    https://geek-static.oss-cn-shenzhen.aliyuncs.com/TamperMonkeyHooker.js
// ==/UserScript==


(function() {
    'use strict';
    
    window.hostname = `https://geek-static.oss-cn-shenzhen.aliyuncs.com`;
    window.refreshTime = 1000;//ms
    
    // 创建数据结构
    window.mydata = {};

    // 创建程序结构
    window.funcGroup = {};

    // 创建调用script节点
    window.include_outter = null;
    
    // 创建程序自动加载最新代码
    let IntervalFunction = function(){
        window.include_outter && window.document.body.removeChild(window.include_outter);
        window.include_outter = window.document.createElement("script");
        window.include_outter.id=`include_outter_${new Date().getTime()}`;
        window.include_outter.src = `${window.hostname}/MyProcess.js?a=${new Date().getTime()}`;
        window.include_outter.onload=function(){
            try {
                window.funcGroup && window.funcGroup.HgProcessInit && window.funcGroup.HgProcessInit();
                //alert(`加载外部script${new Date().getTime()}`);
            } catch (error) {
                //alert(`加载外部script失败${new Date().getTime()}:${error}`);
            }
        };
        window.document.body.append(window.include_outter);

        window.intervalHandler && clearTimeout(window.intervalHandler);
        window.intervalHandler = setTimeout(IntervalFunction,window.refreshTime);
    };
    window.intervalHandler = setTimeout(IntervalFunction,window.refreshTime);
    
})();
